package controller

import (
	"context"

	api "github.com/fastknifes/usdt-pay/internal/http/api/interface/v1"
	"github.com/fastknifes/usdt-pay/internal/http/common/router"
	"github.com/fastknifes/usdt-pay/internal/service"
)

func init() {
	tradeController := Trade{}
	router.RegisterRouter(tradeController.Create)
}

type Trade struct{}

func (td *Trade) Create(_ context.Context, req *api.OrderReq) (res *api.OrderRes, err error) {
	tradeService := service.TradeService{}
	amount, err := tradeService.Create(*req)
	if err != nil {
		return nil, err
	}
	res = &api.OrderRes{
		PayAmount: amount,
	}
	return res, nil
}
